package com.chorye.datasource.controller;

import com.chorye.datasource.entity.Student;
import com.chorye.datasource.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @Company: 北京XXXX有限公司
 * @Author JiangYy
 * @Title: StudentController
 * @Description: TODO
 * @Date 2018/12/13 11:26
 */
@RestController
@RequestMapping("/student")
@Slf4j
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/write")
    public void write() {
        Student student = new Student();
        student.setName("测试思密达");
        student.setAge(11);
        student.setMobile("13512323333");
        student.setAddress("五棵松");
        student.setSalary(new BigDecimal(999));
        int write = studentService.write(student);
        log.info("插入成功的数量" + write);
    }

    @RequestMapping("/read")
    public void read() {
        Student student = studentService.read(1);
        log.info(student.toString());
    }
}
